/*
 * RRscheduler.h
 *
 *  Created on: Jun 25, 2009
 *      Author: yanir
 */

#ifndef RRSCHEDULER_H_
#define RRSCHEDULER_H_

#include "OSScheduler.h"
#include "Mailer.h"
#include <queue>


class RRscheduler : public OSScheduler
{
	//typedef map<string,TT> threadsTable ;
	private:

	queue<Worker*> m_blocked_threads; /* a queue of blocked threads */

	queue<Worker*> m_active_threads;  /* a queue of active threads */

	Mailer* m_mailer;

	map<string, Worker>* m_workers;

	int m_quanta; /* message quanta qiven to the scheduler to work with */

	int m_contex_switch_count;

	int m_quanta_count;

	int m_msg_passed_count;

	int m_phase_count;

//	threadsTable*  m_tT;
	public:

	/* C'tor  */
	RRscheduler();

	RRscheduler(int quanta,map<string, Worker>* workers ,Mailer* mailer);


	virtual ~RRscheduler();


	/* init scheduler*/
	void init();

	/*next worker*/

	void nextWorker();
	//void* getThreadsTable();

	int getQuanta();

	//map<string, Worker>* getWorkers();

	/* increment the contex switches count by 1 */
	void incCScount();

	/* increment the quanta given count by 1 */
	void incQuantaCount();

	/* increment the message passed count by 1 */
	void incMsgPass();

	bool isStable();

	void printSum();

	queue<Worker*>* getActiveThreads();


	int getActiveThreadsSize();

	void emptyQueues();

	int getTotalQuanta();

	int getTotalCS();

	int getTotalMsg();

};


#endif /* RRSCHEDULER_H_ */
